<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>编辑轮播图</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <style>
        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
        }
        .banner-item {
            transition: all 0.3s ease;
        }
        .banner-item:hover {
            transform: translateY(-2px);
            box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
        }
        .drag-handle {
            cursor: move;
        }
        .sortable-ghost {
            opacity: 0.5;
        }
    </style>
</head>
<body class="bg-gray-100">
    <div class="mx-auto max-w-[393px] h-[852px] bg-white relative overflow-hidden rounded-[40px] shadow-2xl">
        <!-- Status Bar -->
        <div class="bg-white px-6 pt-3 pb-2">
            <div class="flex justify-between items-center text-xs">
                <span class="font-semibold">9:41</span>
                <div class="flex space-x-1">
                    <i class="fas fa-signal"></i>
                    <i class="fas fa-wifi"></i>
                    <i class="fas fa-battery-full"></i>
                </div>
            </div>
        </div>

        <!-- Header -->
        <div class="bg-gradient-to-r from-purple-600 to-indigo-600 px-4 py-3">
            <div class="flex items-center justify-between text-white">
                <a href="b2b-store-decoration.html" class="text-white">
                    <i class="fas fa-arrow-left text-lg"></i>
                </a>
                <h1 class="text-lg font-semibold">编辑轮播图</h1>
                <button onclick="saveBanner()" class="text-white hover:opacity-80">
                    <i class="fas fa-save text-lg"></i>
                </button>
            </div>
        </div>

        <!-- Banner Preview -->
        <div class="p-4 bg-gray-50 border-b border-gray-200">
            <h3 class="text-sm font-medium text-gray-700 mb-2">预览效果</h3>
            <div class="relative bg-white rounded-lg overflow-hidden shadow-sm" id="bannerPreview">
                <img src="https://images.unsplash.com/photo-1472851294608-062f824d29cc?w=350&h=180&fit=crop" 
                     alt="轮播图预览" class="w-full h-32 object-cover">
                <div class="absolute bottom-2 right-2 bg-black bg-opacity-50 text-white text-xs px-2 py-1 rounded">
                    1/3
                </div>
            </div>
        </div>

        <!-- Banner Management -->
        <div class="h-[calc(852px-320px)] overflow-y-auto pb-40">
            <!-- Banner List -->
            <div class="p-4">
                <div class="flex items-center justify-between mb-3">
                    <h3 class="font-semibold flex items-center">
                        <span class="w-1 h-4 bg-purple-600 mr-2 rounded-full"></span>
                        轮播图管理 (3/5)
                    </h3>
                    <button onclick="addBanner()" class="text-purple-600 text-sm hover:text-purple-700">
                        <i class="fas fa-plus mr-1"></i>添加图片
                    </button>
                </div>

                <div class="space-y-3" id="bannerList">
                    <!-- Banner 1 -->
                    <div class="banner-item bg-white rounded-lg border border-gray-200 p-3">
                        <div class="flex items-center space-x-3">
                            <div class="drag-handle text-gray-400">
                                <i class="fas fa-grip-vertical"></i>
                            </div>
                            <img src="https://images.unsplash.com/photo-1472851294608-062f824d29cc?w=80&h=60&fit=crop" 
                                 alt="轮播图1" class="w-16 h-12 object-cover rounded">
                            <div class="flex-1">
                                <div class="flex items-center justify-between mb-1">
                                    <p class="text-sm font-medium">轮播图 1</p>
                                    <span class="text-xs bg-green-100 text-green-600 px-2 py-1 rounded">已启用</span>
                                </div>
                                <p class="text-xs text-gray-500">点击跳转: 商品详情页</p>
                            </div>
                            <div class="flex space-x-2">
                                <button onclick="editBannerItem(1)" class="text-blue-600 hover:text-blue-700">
                                    <i class="fas fa-edit text-sm"></i>
                                </button>
                                <button onclick="deleteBannerItem(1)" class="text-red-600 hover:text-red-700">
                                    <i class="fas fa-trash text-sm"></i>
                                </button>
                            </div>
                        </div>
                    </div>

                    <!-- Banner 2 -->
                    <div class="banner-item bg-white rounded-lg border border-gray-200 p-3">
                        <div class="flex items-center space-x-3">
                            <div class="drag-handle text-gray-400">
                                <i class="fas fa-grip-vertical"></i>
                            </div>
                            <img src="https://images.unsplash.com/photo-1556742049-0cfed4f6a45d?w=80&h=60&fit=crop" 
                                 alt="轮播图2" class="w-16 h-12 object-cover rounded">
                            <div class="flex-1">
                                <div class="flex items-center justify-between mb-1">
                                    <p class="text-sm font-medium">轮播图 2</p>
                                    <span class="text-xs bg-green-100 text-green-600 px-2 py-1 rounded">已启用</span>
                                </div>
                                <p class="text-xs text-gray-500">点击跳转: 活动页面</p>
                            </div>
                            <div class="flex space-x-2">
                                <button onclick="editBannerItem(2)" class="text-blue-600 hover:text-blue-700">
                                    <i class="fas fa-edit text-sm"></i>
                                </button>
                                <button onclick="deleteBannerItem(2)" class="text-red-600 hover:text-red-700">
                                    <i class="fas fa-trash text-sm"></i>
                                </button>
                            </div>
                        </div>
                    </div>

                    <!-- Banner 3 -->
                    <div class="banner-item bg-white rounded-lg border border-gray-200 p-3">
                        <div class="flex items-center space-x-3">
                            <div class="drag-handle text-gray-400">
                                <i class="fas fa-grip-vertical"></i>
                            </div>
                            <img src="https://images.unsplash.com/photo-1441986300917-64674bd600d8?w=80&h=60&fit=crop" 
                                 alt="轮播图3" class="w-16 h-12 object-cover rounded">
                            <div class="flex-1">
                                <div class="flex items-center justify-between mb-1">
                                    <p class="text-sm font-medium">轮播图 3</p>
                                    <span class="text-xs bg-gray-100 text-gray-600 px-2 py-1 rounded">已禁用</span>
                                </div>
                                <p class="text-xs text-gray-500">点击跳转: 品牌介绍</p>
                            </div>
                            <div class="flex space-x-2">
                                <button onclick="editBannerItem(3)" class="text-blue-600 hover:text-blue-700">
                                    <i class="fas fa-edit text-sm"></i>
                                </button>
                                <button onclick="deleteBannerItem(3)" class="text-red-600 hover:text-red-700">
                                    <i class="fas fa-trash text-sm"></i>
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Settings -->
            <div class="p-4">
                <h3 class="font-semibold mb-3 flex items-center">
                    <span class="w-1 h-4 bg-purple-600 mr-2 rounded-full"></span>
                    轮播设置
                </h3>
                <div class="bg-white rounded-lg border border-gray-200 p-4">
                    <div class="space-y-4">
                        <!-- Auto Play -->
                        <div class="flex items-center justify-between">
                            <div>
                                <p class="text-sm font-medium">自动轮播</p>
                                <p class="text-xs text-gray-500">自动切换轮播图</p>
                            </div>
                            <label class="relative inline-flex items-center cursor-pointer">
                                <input type="checkbox" checked class="sr-only peer" id="autoPlay">
                                <div class="w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-purple-300 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-purple-600"></div>
                            </label>
                        </div>

                        <!-- Duration -->
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-2">轮播间隔（秒）</label>
                            <select id="duration" class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-transparent">
                                <option value="3">3秒</option>
                                <option value="5" selected>5秒</option>
                                <option value="8">8秒</option>
                                <option value="10">10秒</option>
                            </select>
                        </div>

                        <!-- Show Indicators -->
                        <div class="flex items-center justify-between">
                            <div>
                                <p class="text-sm font-medium">显示指示器</p>
                                <p class="text-xs text-gray-500">底部圆点指示器</p>
                            </div>
                            <label class="relative inline-flex items-center cursor-pointer">
                                <input type="checkbox" checked class="sr-only peer" id="showIndicators">
                                <div class="w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-purple-300 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-purple-600"></div>
                            </label>
                        </div>

                        <!-- Banner Height -->
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-2">轮播图高度</label>
                            <select id="bannerHeight" class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-transparent">
                                <option value="120">120px - 紧凑</option>
                                <option value="150" selected>150px - 标准</option>
                                <option value="180">180px - 宽屏</option>
                                <option value="200">200px - 大图</option>
                            </select>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- Fixed Bottom Action Bar -->
        <div class="absolute bottom-1 left-0 right-0 bg-white border-t border-gray-200 p-4">
            <div class="flex space-x-3">
                <button onclick="previewBanner()" class="bg-gray-100 text-gray-700 font-medium px-4 py-3 rounded-xl hover:bg-gray-200 transition-colors">
                    <i class="fas fa-eye mr-2"></i>预览
                </button>
                <button onclick="saveBanner()" class="flex-1 bg-gradient-to-r from-purple-600 to-indigo-600 text-white font-medium py-3 rounded-xl shadow-lg hover:shadow-xl transition-all duration-200">
                    <i class="fas fa-save mr-2"></i>保存设置
                </button>
            </div>
        </div>
    </div>

    <script>
        // Banner management functions
        function addBanner() {
            if (document.querySelectorAll('.banner-item').length >= 5) {
                showToast('最多只能添加5张轮播图');
                return;
            }
            
            const input = document.createElement('input');
            input.type = 'file';
            input.accept = 'image/*';
            input.onchange = function(e) {
                if (e.target.files[0]) {
                    showToast('正在上传图片...');
                    setTimeout(() => {
                        showToast('图片上传成功');
                        // 模拟添加新轮播图
                        addNewBannerItem(e.target.files[0]);
                    }, 1500);
                }
            };
            input.click();
        }

        function addNewBannerItem(file) {
            const bannerList = document.getElementById('bannerList');
            const newBanner = document.createElement('div');
            newBanner.className = 'banner-item bg-white rounded-lg border border-gray-200 p-3';
            newBanner.innerHTML = `
                <div class="flex items-center space-x-3">
                    <div class="drag-handle text-gray-400">
                        <i class="fas fa-grip-vertical"></i>
                    </div>
                    <img src="https://images.unsplash.com/photo-1578662996442-48f60103fc96?w=80&h=60&fit=crop" 
                         alt="新轮播图" class="w-16 h-12 object-cover rounded">
                    <div class="flex-1">
                        <div class="flex items-center justify-between mb-1">
                            <p class="text-sm font-medium">新轮播图</p>
                            <span class="text-xs bg-green-100 text-green-600 px-2 py-1 rounded">已启用</span>
                        </div>
                        <p class="text-xs text-gray-500">点击跳转: 未设置</p>
                    </div>
                    <div class="flex space-x-2">
                        <button onclick="editBannerItem(${Date.now()})" class="text-blue-600 hover:text-blue-700">
                            <i class="fas fa-edit text-sm"></i>
                        </button>
                        <button onclick="deleteBannerItem(${Date.now()})" class="text-red-600 hover:text-red-700">
                            <i class="fas fa-trash text-sm"></i>
                        </button>
                    </div>
                </div>
            `;
            bannerList.appendChild(newBanner);
            updateBannerCount();
        }

        function editBannerItem(id) {
            const options = [
                '更换图片',
                '设置跳转链接',
                '编辑标题描述',
                '启用/禁用'
            ];
            
            const choice = prompt(`编辑轮播图选项：\n\n1. ${options[0]}\n2. ${options[1]}\n3. ${options[2]}\n4. ${options[3]}\n\n请输入序号 (1-4):`);
            
            if (choice >= 1 && choice <= 4) {
                showToast(`正在${options[choice - 1]}...`);
                setTimeout(() => {
                    showToast('编辑完成');
                }, 1000);
            }
        }

        function deleteBannerItem(id) {
            if (confirm('确认删除这张轮播图吗？\n\n删除后无法恢复。')) {
                showToast('正在删除...');
                setTimeout(() => {
                    // 模拟删除
                    showToast('轮播图已删除');
                    updateBannerCount();
                }, 1000);
            }
        }

        function updateBannerCount() {
            const count = document.querySelectorAll('.banner-item').length;
            document.querySelector('h3 .font-semibold').innerHTML = `
                <span class="w-1 h-4 bg-purple-600 mr-2 rounded-full"></span>
                轮播图管理 (${count}/5)
            `;
        }

        function previewBanner() {
            showToast('正在生成预览...');
            setTimeout(() => {
                showToast('预览功能开发中，敬请期待');
            }, 1000);
        }

        function saveBanner() {
            const settings = {
                autoPlay: document.getElementById('autoPlay').checked,
                duration: document.getElementById('duration').value,
                showIndicators: document.getElementById('showIndicators').checked,
                bannerHeight: document.getElementById('bannerHeight').value
            };

            showToast('正在保存轮播图设置...');
            
            setTimeout(() => {
                showToast('设置保存成功！');
                setTimeout(() => {
                    window.location.href = 'b2b-store-decoration.html';
                }, 1000);
            }, 1500);
        }

        // Toast notification
        function showToast(message) {
            const toast = document.createElement('div');
            toast.className = 'fixed top-20 left-1/2 transform -translate-x-1/2 bg-gray-800 text-white px-4 py-2 rounded-lg text-sm z-50';
            toast.textContent = message;
            document.body.appendChild(toast);
            
            setTimeout(() => {
                toast.remove();
            }, 2000);
        }

        // Initialize page
        document.addEventListener('DOMContentLoaded', function() {
            showToast('轮播图编辑器已加载');
        });
    </script>
</body>
</html>